package com.xxxx.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxxx.server.mapper.IbackMapper;
import com.xxxx.server.pojo.Admin;
import com.xxxx.server.pojo.Iback;
import com.xxxx.server.pojo.RespPageBean;
import com.xxxx.server.service.IIbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 辅导员返校申请 服务实现类
 * </p>
 *
 * @author zhoubin
 * @since 2022-06-02
 */
@Service
public class IbackServiceImpl extends ServiceImpl<IbackMapper, Iback> implements IIbackService {

    @Autowired
    private IbackMapper ibackMapper;

    @Override
    public List<Iback> getIbackByIBId() {
        return ibackMapper.getIbackByIBid(((Admin) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId());
    }

    @Override
    public List<Iback> getIback(Integer id) {
        return ibackMapper.getIback(id);
    }


    @Override
    public RespPageBean getIbackByPage(Integer currentPage, Integer size, Iback iback, String[] beginDateScope) {
        Page<Iback> page = new Page<>(currentPage,size);
        IPage<Iback> IbackByPage = ibackMapper.getIbackByPage(page, iback, beginDateScope);
        RespPageBean respPageBean = new RespPageBean(IbackByPage.getTotal(), IbackByPage.getRecords());
        return respPageBean;
    }






}
